package com.sbl.ui;

import com.sbl.service.IAccountService;
import com.sbl.service.impl.AccountServiceImpl;
import com.sbl.service.impl.AccountServiceImpl2;
import com.sbl.service.impl.AccountServiceImpl3;
import com.sbl.service.impl.AccountServiceImpl4;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 *  模拟表现层
 *      1. Bean对象的属性
 */
public class Client3 {
    public static void main(String[] args) {
        ApplicationContext applicationContext =  new ClassPathXmlApplicationContext("bean3.xml");
        IAccountService iAccountServiceConstructor = applicationContext.getBean("accountServiceByConstructor", AccountServiceImpl2.class);
        iAccountServiceConstructor.saveAccount();

        IAccountService iAccountServiceSet = applicationContext.getBean("accountServiceBySet", AccountServiceImpl3.class);
        iAccountServiceSet.saveAccount();

        //集合注入
        IAccountService iAccountServiceCollection = applicationContext.getBean("accountServiceCollection", AccountServiceImpl4.class);
        iAccountServiceCollection.saveAccount();
    }
}
